﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Runtime.Serialization.Formatters.Binary;
using System.Text;

namespace dotnet2cache.Abstractions.Serialization
{
    public class DataSerializer : IDataSerializer
    {

        public byte[] BinarySerialize<T>(T value)
        {
            using (var ms = new MemoryStream())
            {
                new BinaryFormatter().Serialize(ms, value);
                return ms.ToArray();
            }
        }

        public T BinaryDeserialize<T>(byte[] bytes)
        {
            using (var ms = new MemoryStream(bytes))
            {
                return (T)(new BinaryFormatter().Deserialize(ms));
            }
        }

        public string Serialize<T>(T value)
        {
            throw new NotImplementedException();
        }

        public T Deserialize<T>(string str)
        {
            throw new NotImplementedException();
        }
    }
}
